﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Sec_scan系列弱口令检查系统
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Thread th = new Thread(PortOpen);
            th.Start();
        }
        public void PortOpen()
        {
            richTextBox1.Clear();
            string port = textBox1.Text;
            string ip = textBox2.Text;
            try
            {
                TcpClient k1 = new TcpClient();
                IPAddress iP = IPAddress.Parse(ip);
                IPEndPoint iPEndPoint = new IPEndPoint(iP, Convert.ToInt32(port));
                Socket serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                //创建与远程主机的连接
                serverSocket.Connect(iPEndPoint);
                richTextBox1.Text = "IP地址：" + ip + " -- " + "端口：" + port + " -- " + "开放";
            }
            catch (Exception)
            {
                richTextBox1.Text = "IP地址：" + ip + " -- " + "端口：" + port + " -- " + "未开放";
            }
        }
    }
}
